package com.c2soft.ncmx.exch.mains;

import java.math.BigDecimal;
import java.util.Date;

import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;

import com.c2soft.ncmx.exch.jms.JmsSender;
import com.c2soft.ncmx.exch.pojo.Order;

public class MockOrders {
	
	@Autowired
	private JmsSender jmsSender;
	
	@Value("${ordersending.schedule.sec}")
	private  String scheduledSec;

	@Scheduled(fixedRate = 30 * 1000)	
	private void sendBuyOrders(){
		int[] numTimes={0,1,2,3,4,5,6,7,8,9};
		for(int i:numTimes){
		Order orderBuy=new Order("BUY", "ordrId"+i,"NOT_EXECUTED" ,new BigDecimal("100").add(new BigDecimal(i)), new BigDecimal("120").add(new BigDecimal(i)), 245,  new DateTime(new Date()));
		jmsSender.sendObject(orderBuy);
		}
		
	}
	 @Scheduled(fixedRate = 30 * 1000)	
	private void sendSellOrders(){
		int[] numTimes={0,1,2,3,4,5,6,7,8,9};
		for(int i:numTimes){
		Order orderBuy=new Order("SELL", "ordrId"+i,"NOT_EXECUTED" ,new BigDecimal("100").add(new BigDecimal(i)), new BigDecimal("120").add(new BigDecimal(i)), 245,  new DateTime(new Date()));
		jmsSender.sendObject(orderBuy);
		}
		
	}
}
